﻿using System;
using FS.Business;
using System.Data;
using System.Text;
using System.Collections;
using FS.Common.DotNetUI;
using FS.Web.BLL.Query;
using Microsoft.Reporting.WebForms;

namespace FS.Web.BLL.Report
{
    public partial class Report_PayableAccount : PageBase
    {
        private visa_dao _visa = new visa_dao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetSelect_SupplyInfo();
                initBase_CertType();
                GetSelect_CityInfo();
                GetSelect_InfoFlag();
                GetSelect_MoneyFlag();
                this.databind(null);

                this.begdate.Value = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
                this.enddate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }

        //签证类型
        private void initBase_CertType()
        {
            DataTable dt = _visa.GetSelect_CertType();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_CertType, "property_value", "property_id", "请选择");
        }
        
        //签证国家
        private void GetSelect_CityInfo()
        {
            DataTable dt = _visa.GetSelect_CityInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.cityid, "City_name", "City_id", "请选择");
        }

        //签证状态
        private void GetSelect_InfoFlag()
        {
            DataTable dt = _visa.GetSelect_InfoFlag();
            ControlBindHelper.BindHtmlSelect(dt, this.InfoFlag, "property_value", "property_key", "请选择");
        }

        //签证状态
        private void GetSelect_MoneyFlag()
        {
            DataTable dt = _visa.GetSelect_moneyflag();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_moneyflag, "property_value", "property_key", "请选择");
        }

        //供应商信息
        private void GetSelect_SupplyInfo()
        {
            DataTable dt = _visa.GetSelect_SupplyInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.supplyid, "Supply_Name", "Supply_id", "请选择");
        }

        private void databind(DataTable dt)
        {
            if (dt == null)
            {
                dt = new ds_report().usp_Report_PayableAccount;
                dt.NewRow();
            }
            //this.GridView1.DataSource = dt;
            //this.GridView1.DataBind();

            ReportViewer1.LocalReport.ReportPath = MapPath("/BLL/Query/Report/Report_PayableAccount.rdlc");
            ReportDataSource reportDataSource1 = new ReportDataSource("DataSet1", dt);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(reportDataSource1);
            if (dt != null)
            {
                ReportViewer1.LocalReport.Refresh();
            }
        }

        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            Hashtable ht = new Hashtable();
            ht.Add("startsubmitdate",this.begdate.Value);
            ht.Add("Endsubmitdate",this.enddate.Value);
            ht.Add("Countryid",this.cityid.Value);
            ht.Add("CertType",this.Ref_CertType.Value);
            ht.Add("Supplyid",this.supplyid.Value);
            ht.Add("Ref_moneyflag", this.Ref_moneyflag.Value);
            ht.Add("Info_iscalc",this.Info_iscalc.Value);
            DataTable dt = DataFactory.Run().GetDataTableProc("usp_Report_PayableAccount", ht);

            this.databind(dt);           
        }
    }
}